package com.lixh.sdk.base.http

import java.io.Serializable

/**
 * des:封装服务器返回数据
 * Created by xsf
 * on 2016.09.9:47
 */
open class BaseResPose<T> :
    Serializable {
    var code: Int = 0;
    var msg: String? = null;
    var total: Int = 0;
    var data: T? = null
        get() {
            return field ?: getSubData()
        }
    var message: String? = null
        get() {
            if (field == null) {
                return msg
            }
            return field
        }

    open fun getSubData(): T? {
        return null
    }

    fun success(): Boolean = 200 == code || 0 == code


    override fun toString(): String {
        return "BaseRespose{" +
                "code='" + code + '\''.toString() +
                ", msg='" + message + '\''.toString() +
                ", data=" + data +
                '}'.toString()
    }


}
